#include <stdio.h>
#include <time.h>

static char* wday[] = {
  "Sunday", "Monday", "Tuesday", "Wednesday", 
  "Thursday", "Friday", "Saturday", "Unknown"
};

char* calc_week(int year, int month, int day)
{
  struct tm time;

  time_t t;
  time.tm_year = year-1900;
  time.tm_mon = month-1;
  time.tm_mday = day;
  time.tm_hour = 14;

  time.tm_min = 27; 
  time.tm_sec = 1; 

 
  if( (t=mktime(&time)) == (time_t)(-1) )
    return wday[7];
  else {
    puts(asctime(&time));
    puts(asctime(gmtime(&t)));
    puts(ctime(&t));
    printf("yday: %d\n",time.tm_yday);
    printf("wday: %d\n",time.tm_wday);
    return wday[time.tm_wday];
  }
}

int main()
{
  int year,month,day;
  
  printf("enter year: "); scanf("%d",&year);
  printf("enter month: ");scanf("%d",&month);
  printf("enter day: ");  scanf("%d",&day);

  printf("That day is a %s.\n",calc_week(year,month,day) );
  return 0;
}
